package com.liwy3.gateway.filter;

import lombok.SneakyThrows;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * Copyright © 元气森林（北京）食品科技集团有限公司. All rights reserved.
 *
 * @Description:
 * @author: Crazy4J
 * @date: 2021年12月07日 14:23
 * @version: V1.0
 */
@Configuration
public class GlobalFilterConfiguration {

    @Bean
    public GlobalFilter testGlobalFilter(){
        return (exchange, chain) -> {
            String first = exchange.getRequest().getHeaders().getFirst("X-Request-TOKEN");
            if (StringUtils.hasLength(first)){
                System.out.println("fangxing");
            }
            return chain.filter(exchange);
        };
    }
}
